local skel = fk.CreateSkill {
  name = "lb__yunhui",
  dynamic_desc = function (self, player, lang)
    local suits = player:getTableMark("@[suits]lb__yunhui")
    if #suits == 0 then
      return "lb__yunhui"
    else
      return "lb__yunhui_inner:" .. table.concat(table.map(suits, function(suit)
        return Fk:translate(Card.getSuitString({ suit = suit }, true))
      end), "")
    end
  end,
}

Fk:loadTranslationTable {
  ["lb__yunhui"] = "蕴慧",
  --[":lb__yunhui"] = "你可以将一张（<font color='red'>♦</font>或♣）牌当<a href='bag_of_tricks'>智囊牌</a>使用并移除括号内对应的花色，且不能与上次转化的牌名相同。",
  --10.25
  [":lb__yunhui"] = "你可以将一张（<font color='red'>♦♥</font>♣♠）牌当<a href='bag_of_tricks'>智囊牌</a>使用并移除括号内对应的花色，且不能与上次转化的牌名相同。",

  [":lb__yunhui_inner"] = "你可以将一张（{1}）牌当<a href='bag_of_tricks'>智囊</a>牌使用并移除括号内对应的花色，且不能与上次转化的牌名相同。",

  ["#lb__yunhui"] = "蕴慧：你可以将一张（%arg）牌当智囊牌使用并移除括号内对应的花色",

  ["@lb__yunhui"] = "蕴慧",
  ["@[suits]lb__yunhui"] = "蕴慧",

  ["$lb__yunhui1"] = "这次能让我玩的开心点吗？",
  ["$lb__yunhui2"] = "战斗体验该优化了。",
  ["$lb__yunhui3"] = "来点刺激的！",
}
skel:addEffect("viewas", {
  pattern = "ex_nihilo,dismantlement,nullification",
  prompt = function(self, player, selected_cards, selected)
    return "#lb__yunhui:::" .. table.concat(table.map(player:getTableMark("@[suits]lb__yunhui"), function(suit)
      return Fk:translate(Card.getSuitString({ suit = suit }, true))
    end), "/")
  end,
  interaction = function(self, player)
    local all_names = { "ex_nihilo", "dismantlement", "nullification" }
    local names = player:getViewAsCardNames(
      skel.name,
      all_names,
      nil,
      {player:getMark("@lb__yunhui")}
    )
    if #names == 0 then return end
    return UI.CardNameBox { choices = names, all_choices = all_names }
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and table.contains(player:getTableMark("@[suits]lb__yunhui"), Fk:getCardById(to_select).suit)
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 or not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcards(cards)
    card.skillName = skel.name
    return card
  end,
  before_use = function(self, player, use)
    player.room:removeTableMark(player, "@[suits]lb__yunhui", use.card.suit)
    player.room:setPlayerMark(player, "@lb__yunhui", self.interaction.data)
  end,
  enabled_at_play = function(self, player)
    return #player:getTableMark("@[suits]lb__yunhui") > 0 and not player:isNude()
  end,
  enabled_at_response = function(self, player, response)
    return #player:getTableMark("@[suits]lb__yunhui") > 0 and not player:isNude() and not response
  end,
})

skel:addAcquireEffect(function(self, player, is_start)
  player.room:setPlayerMark(player, "@[suits]lb__yunhui", { Card.Diamond, Card.Heart, Card.Club, Card.Spade})
end)

skel:addLoseEffect(function(self, player, is_death)
  player.room:setPlayerMark(player, "@lb__yunhui", 0)
  player.room:setPlayerMark(player, "@[suits]lb__yunhui", 0)
end)

return skel